<template>
  <div>
    <el-button @click="closeDrawer()" size="small" type="primary">导入模板下载</el-button>
    <div style="margin:20px 0"></div>
    <importFile
      :title="'导入'"
      :actionUrl="urls"
      @close="closeHandler"
    />

    <div style="height:47px;"></div>
  </div>
</template>
<script>
import {downloadColor} from '@/api/omSale/vehicleParameters/vehicleColour/index.js';
import {excelList1} from '@/api/omSale/vehicleParameters/vehicleMaterials/index.js';
import {downloadUrl} from '@/utils'
import moment from 'moment'
import { exportExcelFile } from '@/utils';
export default {
  data(){
    return{
      urls:'/api/basedata/vehicleProduct/productInfo/productImportFromExcel1',
      fetchParams:{

      },
      fetchApi:()=>{},
    }
  },
  methods:{
    closeDrawer(type){
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
          confirmButtonText: '下载',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {

          // downloadUrl('https://bjev-cms-oss-public.oss-cn-beijing.aliyuncs.com/整车物料导入模板.xlsx','整车物料导入');
          let json = this.fetchParams;
          this.exportLoading = true;

          excelList1(json)
            .then(response => {
              exportExcelFile(response.data, '整车物料导入');
              this.exportLoading = false;
            })
            .catch(err => {
              console.log(err);
            });

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
    },
    closeHandler(val){
      console.log(val,'val')
      if(val[0].url.result=="success"){
        this.$emit('close',val[0].url.resultList)
      }else{
        this.$emit('close',[])
      }
    },

  },
}

</script>
